#include "sendverificationcode.h"

SendVerificationCode *SendVerificationCode::sendcodehand = nullptr;

SendVerificationCode::SendVerificationCode(QObject *parent) : QObject(parent)
{

}

void SendVerificationCode::send(QString phone_num, QString verification_code)
{
    QProcess* qprocess = new QProcess(this);
//    qprocess->start(QString("python3 ") + QString("/home/ubuntu/Documents/QChat/Server/main.py ") + phone_num + QString(" ") + verification_code);
    verification_code_data.push_back(verification_code);
    qprocess->waitForStarted();
    qprocess->waitForFinished();
    delete qprocess;
}
bool SendVerificationCode::CheckNumber(QString verification_code)
{
    bool res = false;
    for(int i = 0;i < verification_code_data.size();i++)
    {
        if(verification_code_data[i] == verification_code)
        {
            res = true;
            verification_code_data[i] = "0000";
            break;
        }
    }
    return res;
}
